package com.shaobufan.museum.controllar;

import com.shaobufan.museum.common.BaseResponse;
import com.shaobufan.museum.common.ResultUtils;
import com.shaobufan.museum.pojo.request.user.UserExhibitMomentRequest;
import com.shaobufan.museum.pojo.vo.MuseumExhibitVo;
import com.shaobufan.museum.service.UserExhibitMomentService;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/booking")
public class UserExhibitMomentController {
    @Resource
    UserExhibitMomentService userExhibitMomentService;

    @ApiOperation("添加预约")
    @PostMapping("/add")
    public BaseResponse<Boolean> addBooking(@RequestBody UserExhibitMomentRequest userExhibitMomentRequest) {
        Integer userId = userExhibitMomentRequest.getUserId();
        Integer exId = userExhibitMomentRequest.getExId();
        Integer moId = userExhibitMomentRequest.getMoId();

        Boolean added = userExhibitMomentService.addUserExhibitMoment(userId, exId, moId);

        return ResultUtils.success(added, "成功添加");
    }

    @ApiOperation("获取展览详细")
    @GetMapping("/get/{params}")
    public BaseResponse<List<MuseumExhibitVo>> getBooking(@PathVariable Integer params) {
        List<MuseumExhibitVo> museumExhibitVoList = userExhibitMomentService.searchUserExhibitByUserid(params);
        return ResultUtils.success(museumExhibitVoList, "展览详细");
    }
}
